{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from ase.visualize import view\n",
    "from ase.io import read\n",
    "from ase.io.trajectory import TrajectoryWriter,Trajectory\n",
    "from irff.structures import structure\n",
    "from irff.molecule import Molecules,SuperCell,moltoatoms\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<font color=yellow size=4>铝层(下)</font>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cell([32.4, 32.4, 8.1])\n"
     ]
    }
   ],
   "source": [
    "Al_lower = structure('Al')\n",
    "Al_lower = Al_lower*[8,8,2]\n",
    "cellAl = Al_lower.get_cell()\n",
    "print(cellAl)\n",
    "# view(Al_lower)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<font color=yellow size=4>氟聚物层</font>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cell([28.5, 32.5, 6.5])\n"
     ]
    }
   ],
   "source": [
    "F = read('Polytetrafluoro_ethylene.gen')\n",
    "F = F*[1,5,1]\n",
    "cellF = F.get_cell()\n",
    "print(cellF)\n",
    "# view(F)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<font color=yellow size=4>摞在一起</font>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "atomsAll = Al_lower.copy()\n",
    "for atom in F:\n",
    "    atom.z = atom.z+cellAl[2][2]\n",
    "    atomsAll.append(atom)\n",
    "atomsAll.set_cell([max(cellAl[0][0],cellF[0][0]),\n",
    "                   max(cellAl[1][1],cellF[1][1]),\n",
    "                   cellAl[2][2]+cellF[2][2]])\n",
    "# view(atomsAll)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<font color=yellow size=4>铝层(上)</font>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "for atom in Al_lower:\n",
    "    atom.z = atom.z+cellAl[2][2] + cellF[2][2]\n",
    "    atomsAll.append(atom)\n",
    "atomsAll.set_cell([max(cellAl[0][0],cellF[0][0]),\n",
    "                   max(cellAl[1][1],cellF[1][1]),\n",
    "                   2.0*cellAl[2][2]+cellF[2][2]])\n",
    "view(atomsAll)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
